@extends('layouts.header')
@section('style')
        .input-ip{
            -webkit-appearance: auto!important;
            text-align: center;
            width: 100px;
        }
        #remote_ip-error{
            left: 91px;
            top: -16px;
        }
        .form legend {
            font-size: 14px;
        }
@endsection
@section('content')
    <article class="page-container">
        <form class="form form-horizontal" id="form" autocomplete="off" >
            <fieldset>
                <legend>条形码标签设置:</legend>
                <div class="row cl">
                    <label class="form-label col-sm-3">打印深度：</label>
                    <div class="formControls col-sm-9">
                        <span class="select-box" style="width: 70px">
                            <select class="select" size="1" name="depth">
                                @foreach ([3,4,5,6,7,8,9,10,11,12,13,14,15] as $item)
                                    <option value="{{$item}}"
                                        @if ($item == (isset($data['depth'])?$data['depth']:12) )
                                            selected
                                        @else
                                            @empty($data)
                                                @if ($item === 12 )
                                                    selected
                                                @endif
                                            @endempty
                                        @endif
                                    >
                                        {{$item}}
                                    </option>
                                @endforeach
                            </select>
                        </span>
                        <label style="color: #999!important;">默认值：12，数值越大打印越清晰，但数值过大会影响打印头寿命</label>
                    </div>
                </div>

                <div class="row cl">
                    <label class="form-label col-sm-3">打印方式：</label>
                    <div class="formControls col-sm-9 ">
                        <div class="">
                            <input type="radio" id="radio-5" name="is_remote" value="0" @if (isset($data['is_remote']) && $data['is_remote']==0)checked @endif>
                            <label for="radio-5">本机打印</label>
                            <label style="color: #999!important;margin-left:109px">只能用连接打印机的电脑打印</label>
                        </div>
                        <div class="">
                            <input type="radio" id="radio-6" name="is_remote" value="1" @if (isset($data['is_remote']) && $data['is_remote']==1)checked @endif>
                            <label for="radio-6">远程打印</label>
                            <input type="text" class="input-ip" value="{{ isset($data['remote_ip']) ? $data['remote_ip'] : '127.0.0.1' }}" placeholder="" name="remote_ip">
                            <label style="color: #999!important;">与连接打印机的电脑在同一局域网即可打印</label>
                        </div>
                        <br><label style="color: rgb(216, 29, 29)!important;">选择远程打印时必须填写与打印机连接的电脑的IP地址<a href="https://jingyan.baidu.com/article/63f236287de2c70208ab3de4.html" target="_blank" class="btn btn-link">如何查看IP地址？</a></label>
                    </div>
                </div>
            </fieldset>

            <fieldset class="@if(!$enable_tool_ID)hide @endif">
                <legend>RFID标签设置:</legend>
                <div class="row cl">
                    <label class="form-label col-sm-3">打印方式：</label>
                    <div class="formControls col-sm-9 ">
                        <div class="">
                            <input type="radio" id="radio-7" name="is_remote_RFID" value="0" @if ($data['is_remote_RFID']==0)checked @endif>
                            <label for="radio-7">本机打印</label>
                            <label style="color: #999!important;margin-left:109px">只能用连接打印机的电脑打印</label>
                        </div>
                        <div class="">
                            <input type="radio" id="radio-8" name="is_remote_RFID" value="1" @if ($data['is_remote_RFID']==1)checked @endif>
                            <label for="radio-8">远程打印</label>
                            <input type="text" class="input-ip" value="{{ $data['remote_ip_RFID'] }}" placeholder="" name="remote_ip_RFID">
                            <label style="color: #999!important;">与连接打印机的电脑在同一局域网即可打印</label>
                        </div>
                        <br><label style="color: rgb(216, 29, 29)!important;">选择远程打印时必须填写与打印机连接的电脑的IP地址<a href="https://jingyan.baidu.com/article/63f236287de2c70208ab3de4.html" target="_blank" class="btn btn-link">如何查看IP地址？</a></label>
                    </div>
                </div>
            </fieldset>
            @csrf

            <div class="row cl pt-20">
                <div class="col-sm-9 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
    <script type="text/javascript">
        $(function(){

            var index2;

            $("#form").validate({
                rules:{
                    remote_ip:{
                        ip:true,
                    },

                },
                // onkeyup:false,
                // focusCleanup:false,
                success:"valid",
                submitHandler:function(form){
                   $(form).ajaxSubmit({
                        type: 'post',
                        url: "",//自己提交给自己可以不写url
                        //beforeSend  beforeSubmit

                        beforeSend : function () {
                            //0.4透明度 白色遮罩
                           index2 = layer.load(2,{ shade: [0.3,'#fff'] });
                        },
                        complete : function () {
                            layer.close(index2);
                        },
                        success: function(data) {
                            //判断添加结果
                            if(data === '1'){
                                parent.window.location.reload();//刷新
                                // parent.table_reload(0);//0停留在当前页，1回到第一页
                                parent.parent.layer.msg('操作成功!',{ icon: 1, time:2000 });
                                layer_close();
                            }else{
                                layer.msg('操作失败!', { icon: 2, time: 2000 });
                            }
                        },
                        error: function(data) {
                            ajax_error(data);
                        }
                    });
                }
            });
        });
    </script>
@endsection
